/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CriteriaOutputJPanel.java
 *
 * Created on Jun 24, 2011, 8:03:44 PM
 */

package presentation.guiForDecisionAlgorithmEvaluation;

import java.util.TreeMap;
import javax.swing.JLabel;
import layout.TableLayout;

/**
 *
 * @author Dinh
 */
public class CriteriaOutputJPanel extends javax.swing.JPanel {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private TreeMap<String, Double> outputValue;

    /** Creates new form CriteriaOutputJPanel */
    public CriteriaOutputJPanel(TreeMap<String, Double> outputValue) {
        this.outputValue = outputValue;
        initComponents();
        initOtherComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

        private void initOtherComponents() {

        //create table layout
        int border = 10;
        double size[][] = new double[2][];
        size[0] = new double[4];
        size[0][0] = border;
        size[0][1] = TableLayout.PREFERRED;
        size[0][2] = TableLayout.PREFERRED;
        size[0][3] = border;

        size[1] = new double[outputValue.size() + 2];
        size[1][0] = border;
        for (int i = 1; i < size[1].length - 1; ++i) {
            size[1][i] = TableLayout.PREFERRED;
        }
        size[1][size[1].length - 1] = border;

        this.setLayout(new TableLayout(size));

        //add components
        int i = 1;
        for (String parameterName : outputValue.keySet()) {
            JLabel jLabel = new JLabel(parameterName + ":");
            this.add(jLabel, "1, " + i);

            jLabel = new JLabel(outputValue.get(parameterName).toString());
            this.add(jLabel, "2, " + i);

            i++;
        }

    }

}
